-
Notifications
You must be signed in to change notification settings - Fork 1.5k
sqlx-core pools optionally immediately return ConnectionRefused errors instead of hanging and returning PoolTimedOut #3929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
made it optional with the |
01373ef
to
3e77113
Compare
it is now possible to set return_con_refused to true so that connection refused errors are immediately returned instead of hanging until the timeout and returning a PoolTimedOut error
3e77113
to
1583df2
Compare
hey @abonander could this get a review ? |
This comment was marked as spam.
This comment was marked as spam.
@mehcode sorry for the bump but could this get a review ? |
There's kind of two orthogonal issues here:
I've been slowly working on #3582 which should bring massive improvements in this regard, including a separately settable |
@abonander hey, thank you for the reply ! no, i don't necessarily want to die on the first error but i want to be able to manage it myself, there are services that if they can't connect first try, i don't want to have to wait for the whole timeout. ie connecting to a local database when the database is down and i'm testing things, i rather have the service exit immediately than wait for no reason. or i want to connect to another backup database if the first one failed, that kind of things. there are also many case in which if the database actualy went offline, i want to return to the user immediately that there was an internal error and not make him wait for 30s. i rather have the user retry than wait for nothing in many cases. we know the connection failed, and thus i don't think that information should be hidden from the library user if he wants to be able to get it, no other databases library i know of does that. either way, this behavior should be a choice, this is why i made it an option and i rather not have to maintain a fork just to be able to do that. if i want to write my own retry and wait logic, or have none, i should be able to. |
instead of hanging until the timeout and returning a PoolTimedOut error
Does your PR solve an issue?
fixes #744
this also would fix a bunch of duplicate / similar issues, didn't take the time to list them all.
Is this a breaking change?
following the last commit, no, it's a new options when creating the pool.
as mentioned by my comment in the issue :
if your db goes down you don't want users to have to wait a few seconds to get an error when they could get some 500 error immediately.
i understand that the pr may need some edits, but i wanted this issue to get some attention.